package com.anyou.mall.goo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.anyou.common.annotation.ShopScope;
import com.anyou.mall.goo.goods.domain.GooGoods;
import com.anyou.mall.goo.goodsSku.domain.GooGoodsSku;
import com.anyou.mall.goo.param.AddGoodsSuitParam;
import com.anyou.mall.goo.vo.GoodsSuitDetailsVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.goo.domain.GoodsSuit;
import com.anyou.mall.goo.service.IGoodsSuitService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 套装管理Controller
 *
 * @author gaochaohao
 * @date 2022-04-08
 */
@Api(tags = "套装管理")
@RestController
@RequestMapping("/goo/goodsSuit2")
public class GoodsSuitController2 extends BaseController
{
    @Autowired
    private IGoodsSuitService goodsSuitService;

    /**
     * 查询套装管理列表
     */
    @ApiOperation("查询套装管理列表")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:list')")
    @GetMapping("/list")
    @ShopScope(baseTableAlias="b")
    public TableDataInfo<List<GoodsSuit>> list(GoodsSuit goodsSuit)
    {
        startPage();
        List<GoodsSuit> list = goodsSuitService.selectGoodsSuitList(goodsSuit);
        return getDataTable(list);
    }

    /**
     * 导出套装管理列表
     */
    @ApiOperation("导出套装管理列表")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:export')")
    @Log(title = "套装管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(GoodsSuit goodsSuit,HttpServletResponse response)
    {
        List<GoodsSuit> list = goodsSuitService.selectGoodsSuitList(goodsSuit);
        ExcelUtil<GoodsSuit> util = new ExcelUtil<GoodsSuit>(GoodsSuit.class);
        util.exportExcel(response, list, "套装管理数据");
    }

    /**
     * 获取套装商品详细信息
     */
    @ApiOperation("获取套装商品详细信息")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:query')")
    @GetMapping(value = "/{goodsSuitId}")
    public ApiResult<GoodsSuitDetailsVo> getInfo(@PathVariable("goodsSuitId") Long goodsSuitId)
    {
        return ApiResult.success(goodsSuitService.selectGoodsSuitByGoodsSuitId(goodsSuitId));
    }

    /**
     * 新增套装管理
     */
/*    @ApiOperation("新增套装管理")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:add')")
    @Log(title = "套装管理", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody GoodsSuit goodsSuit)
    {
        return ApiResult.success(goodsSuitService.insertGoodsSuit(goodsSuit));
    }*/

    /**
     * 修改套装管理
     */
/*    @ApiOperation("修改套装管理")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:edit')")
    @Log(title = "套装管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody GoodsSuit goodsSuit)
    {
        return ApiResult.success(goodsSuitService.updateGoodsSuit(goodsSuit));
    }*/

    /**
     * 删除套装管理
     */
    @ApiOperation("删除套装管理")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:remove')")
    @Log(title = "套装管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{goodsSuitIds}")
    public ApiResult remove(@PathVariable Long[] goodsSuitIds)
    {
        return ApiResult.success(goodsSuitService.deleteGoodsSuitByGoodsSuitIds(goodsSuitIds));
    }

    /**
     * 根据商家获取商家商品名称列表
     */
    @ApiOperation("根据商家编号获取商家商品名称列表")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:goodsName')")
    @GetMapping("/goodsName/{storeId}")
    public ApiResult<List<GooGoods>> goodsName(@PathVariable Long storeId)
    {
        return goodsSuitService.goodsName(storeId);
    }

    /**
     * 根据商家获取商家商品名称列表
     */
    @ApiOperation("根据商品编号获取SKU组合列表")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:goodsSkuList')")
    @GetMapping("/goodsSkuList/{goodsId}")
    public ApiResult<List<GooGoodsSku>> goodsSkuList(@PathVariable Long goodsId)
    {
        return goodsSuitService.goodsSkuList(goodsId);
    }

    /**
     * 根据商家获取商家商品名称列表
     */
    @ApiOperation("新增套装")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:add')")
    @PostMapping("/addGoodsSuit")
    public ApiResult addGoodsSuit(@RequestBody AddGoodsSuitParam add)
    {
        return goodsSuitService.addGoodsSuit(add);
    }

    @ApiOperation("修改套装")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:edit')")
    @PostMapping("/updateGoodsSuit")
    public ApiResult updateGoodsSuit(@RequestBody AddGoodsSuitParam add)
    {
        return goodsSuitService.updateGoodsSuit(add);
    }

    /**
     * 根据商家获取商家商品名称列表
     */
    @ApiOperation("套装上下架")
    @PreAuthorize("@ss.hasPermi('goo:goodsSuit2:shelfStatus')")
    @PostMapping("/shelfStatus")
    public ApiResult shelfStatus(@RequestBody GoodsSuit shelfStatus)
    {
        return goodsSuitService.shelfStatus(shelfStatus);
    }


}

